<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Admin
 *
 * @author TOP   SYSTEM
 */
class Admin {
   // var $s=10;
    public function Update_product($id){
        
    if(isset($_POST['update']))
    {
$con=mysqli_connect("localhost","root","","book_market");
// Check connection
if (mysqli_connect_errno()) 
{
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
 }

$Product_name = $_POST['Product_name'];
$Quantity = $_POST['Quantity'];
$Price = $_POST['Price'];
$Description=$_POST['Description'];
if(!empty($_POST['file'])){
   $img=$_POST['file'];
   mysqli_query($con,"UPDATE product 
       SET Product_Name = '$Product_name'
       , Quantity = '$Quantity'
        , Price = '$Price'
        , Image_Src = '$img'
        , Description = '$Description'   
        WHERE Product_Id ='$id' ") or die("Error". mysql_error());
}
else {
mysqli_query($con,"UPDATE product 
       SET Product_Name = '$Product_name'
       , Quantity = '$Quantity'
       , Price = '$Price '
       , Description = '$Description'
        WHERE Product_Id ='$id' ") or die("Error". mysql_error());

}
mysqli_close($con);
   
}

    }
     public function Delete_product($idd){
     $con=mysqli_connect("localhost","root","","book_market");
// Check connection
if (mysqli_connect_errno()) 
{
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
 }
 
 mysqli_query($con,"DELETE FROM product WHERE Product_Id = " . mysql_real_escape_string($idd)) or die("Error". mysql_error());
 mysqli_close($con);
     }
     ////////////////////////////////

     /////////////////////////////////////////
     public function Add_Product(){
   //@include "connection.php"; 
     $con=mysqli_connect("localhost","root","","book_market")
                or die(mysqli_connect_error());
     
if(isset($_POST['add'])){
//$Category_Id=$_POST['Category'];
$Product_Name=$_POST['Product_name'];
$Quantity=$_POST['Quantity'];
$Price=$_POST['Price'];
$Description=$_POST['Description'];
$Image_Src=$_POST['file'];

$query="INSERT INTO product (Product_Id,Category_Id,Product_Name,Quantity,Price,Image_Src,Description) 
    VALUES('','2','$Product_Name','$Quantity','$Price' , '$Image_Src', '$Description')";
mysqli_query($con,$query) or die("Error" .  mysql_error());
    echo $Product_Name;
     echo $Quantity;
}
 mysqli_close($con);
}

}

?>
